/*
 * @Descripttion: 
 * @version: 
 * @Author: 
 * @Date: 2022-04-24 09:01:49
 * @LastEditors: weidelong
 * @LastEditTime: 2022-05-09 16:54:18
 */
import { createApp } from 'vue'
import App from './App.vue'
import store from "./store"
import router from './router'
import { createPinia } from 'pinia';
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import axios from 'axios'
import VueAxios from 'vue-axios'
import * as Icons from '@element-plus/icons-vue'
import myxss from './utils/xss.js'
import {v4}  from 'uuid'
import VueSocketIO from 'vue-3-socket.io'
import io from 'socket.io-client'

const app = createApp(App)

app.config.globalProperties.$xss = (val) => {
	return myxss.process(val)
}
app.config.globalProperties.$uid = v4

//方法--全局挂载响应图表
app.config.globalProperties.$echartsResize = function(ref){
    window.addEventListener('resize',function () {
        ref.resize()
    })
}

// socket 连接参数
const socketOptions = {
    autoConnect: false,       // 是否自动连接
    transports : ['websocket']
}
const socketio = new VueSocketIO({
    // debug: true,
    connection: io('http://localhost:3001', socketOptions),
    vuex: {
        store,
        actionPrefix: 'SOCKET_',
        mutationPrefix: 'SOCKET_'
    },
    extraHeaders: {"Access-Control-Allow-Origin": '*'},
})



for (const [key, value] of Object.entries(Icons)){
	app.component(key, value)
}

app.use(store).use(router).use(ElementPlus).use(VueAxios, axios).use(createPinia()).use(socketio).mount('#app')